< previous page page_545 next page >

Page 545
    Err.Raise vbObjectError + 1, "errHandler.LogError", "Can't write log file ["
arrow.gif& errLogFileName & "]"
    '
End Sub
It is especially important to use this method for marking errors when you are coding ActiveX DLL servers. Since servers may run at a remote location on the network, you cannot be sure that users ever see any error dialog you display. Also, remember that, even if the DLL is running on the local PC, error dialog boxes are application-modal. No other processing occurs until the dialog box is dismissed. You learn to use the Err.Raise method when you create your errHandler object library later in this chapter.
So far, you have seen how to build a simple error handler and the different ways to exit error handlers. Now you need to learn about the different types of errors that you may encounter in your Visual Basic programs and how to plan for them in advance.
Types of Errors
In order to make writing error handlers easier and more efficient, you can group errors into typical types. These error types can usually be handled in a similar manner. When you get an idea of the types of errors you may encounter, you can begin to write error handlers that take care of more than one error. You can write handlers that take care of error types.
There are four types of Visual Basic errors:
· General file errors: These are errors you encounter when you are attempting to open, read, or write simple files. This type of error does not include errors related to internal database operations (read/write table records).
· Physical media errors: These are errors caused by problems with physical deviceserrors such as unresponsive communications ports or printers and low-level disk errors (Unable To Read Sector, and so on).
· Program code errors: These are errors that appear in your programs due to problems with your code. Errors include Divide by zero, Invalid Property, and other errors that can only be corrected by changing the Visual Basic code in your programs.
· Database errors: These are errors that occur during database operations, usually during data read/write or data object create/delete operations.
Each of these types of errors needs to be handled differently within your Visual Basic programs. You learn general rules for handling these errors in the following sections.

 
< previous page page_545 next page >

If you like this book, buy it!